]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
[ShellAppSystem] Initialize collation keys for info on-demand
authorColin Walters <walters@verbum.org>
Fri, 18 Dec 2009 17:29:25 +0000 (12:29 -0500)
committerColin Walters <walters@verbum.org>
Fri, 18 Dec 2009 17:36:16 +0000 (12:36 -0500)
In case of duplicate infos structures with the same id, the
info structures we get from looking up the id in app_id_to_info
aren't necessarily the same as those we used to match, so we
can't rely on matching to implicitly initialize info->casefolded_name.

Since the name collation key isn't used in matching results,
just in sorting, init it on-demand in the sorting which is also more
efficient.

src/shell-app-system.c

index ffe3ccc2a5fad42cebe1886f00fa0fd12ce6a1e7..ab609ec1f47c62de5d00860738d69cb863dff7c7 100644 (file)
@@ -622,7 +622,6 @@ shell_app_info_init_search_data (ShellAppInfo *info)
 
   name = gmenu_tree_entry_get_name ((GMenuTreeEntry*)info->entry);
   info->casefolded_name = normalize_and_casefold (name);
-  info->name_collation_key = g_utf8_collate_key (name, -1);
 
   comment = gmenu_tree_entry_get_comment ((GMenuTreeEntry*)info->entry);
   info->casefolded_description = normalize_and_casefold (comment);
@@ -675,6 +674,11 @@ shell_app_info_compare (gconstpointer a,
   ShellAppInfo *info_a = g_hash_table_lookup (system->priv->app_id_to_info, id_a);
   ShellAppInfo *info_b = g_hash_table_lookup (system->priv->app_id_to_info, id_b);
 
+  if (!info_a->name_collation_key)
+    info_a->name_collation_key = g_utf8_collate_key (gmenu_tree_entry_get_name ((GMenuTreeEntry*)info_a->entry), -1);
+  if (!info_b->name_collation_key)
+    info_b->name_collation_key = g_utf8_collate_key (gmenu_tree_entry_get_name ((GMenuTreeEntry*)info_b->entry), -1);
+
   return strcmp (info_a->name_collation_key, info_b->name_collation_key);
 }